﻿@using ST = EmoneyWeiXinCommon.StringTools;
@using EmoneyWeiXinEntity;
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    ViewBag.Title = "二维码统计详细";
}
<div class="right">
    <h3>二维码统计详细</h3>
    <!--manage-->
    <div class="manage">
        <p class="manage_line"></p>
        <div class="manage_register">
            <p><span>二维码名称：</span><span id="tName"></span></p>
            <p><span>启用日期：</span><span id="tDate"></span></p>
        </div>
        <!--manage_bottom-->
        <div class="manage_bottom">
            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                <tr>
                    <th><span>编号</span></th>
                    <th><span>关注者昵称</span></th>
                    <th><span>OPENID</span></th>
                    <th><span>关注时间</span></th>
                    <th><span>当前状态</span></th>
                </tr>
                <tbody id="dvList">
                </tbody>

            </table>
            <div class="manage_page" id="manage_page">
            </div>
        </div>
        <!--manage_bottom end-->
    </div>
    <!--manage end-->
    <h3><a href="@ST.GetTrendsFile("TwoCode/TwoCodeStat?leftid=" + ViewBag.leftid)">返回</a></h3>
</div>
<script type="text/javascript">
    var pageIndex = 1;
    var pageSize = 10;
    var pageCount = 1;
    var totalCount = 0;
    $(document).ready(function () {
        var tname = "@ViewBag.name";
        var tdate = "@ViewBag.date";
        $("#tName").text(tname);
        $("#tDate").text(tdate);
        gotoPage();
        //查询
        $("#btnQuery").click(function () {
            if (ischeck())
                pageIndex = 1;
            gotoPage();
        });
    });

    var ajaxdata = {};
    function gotoPage() {
        var value = "@ViewBag.value";
        var weixinid = "@ViewBag.weixinid";
        ajaxdata["weixinid"] = weixinid;
        ajaxdata["index"] = pageIndex;
        ajaxdata["size"] = pageSize;
        ajaxdata["value"] = value;
        $.ajax({
            url: "@ST.GetTrendsFile("TwoCode/GetTwoCodeStatDetail")",
            type: "POST",
            async: true,
            data: ajaxdata,
            beforeSend: function () {
                //showLoading();
            },
            complete: function () {
                //iddenLoading();
            },
            success: function (result) {
                if (result != "" && result != null && result != undefined) {
                    var arrData = result.split("~");
                    totalCount = arrData[0];
                    var data = arrData[1];
                    var d = eval(data);
                    var html = "";
                    for (var i = 0; i < d.length; i++) {
                        html += "<tr>";
                        html += getTxtTd(d[i]["rowid"]) + getTxtTd(d[i]["nickname"]) + getTxtTd(d[i]["FromUserName"]);
                        html += getTxtTd(d[i]["createtime"]) + getTxtTd(d[i]["status"]);
                        html += "</tr>";
                    }

                    $("#dvList").html(html);
                    PageCountHtml();
                } else {
                    $("#dvList").html("没有查询到相关数据!");
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                //alert(errorThrown);
            }
        });
    }
    function getTxtTd(s) {
        return '<td><span>' + s + '</span></td>';
    }

    function PageCountHtml() {
        pageCount = Math.ceil(totalCount / pageSize);
        if (pageCount == 0) {
            pageCount = 1;
        }
        $("#manage_page").html(PageHtml(pageIndex, pageCount));
        $("#manage_page .manage_page_right").click(function () {
            pageIndex = parseInt($("#txtPageNum").val()) + parseInt($(this).attr("tname"));
            $("#manage_page").html(PageHtml(pageIndex, pageCount));
            gotoPage();
        });
        $("#manage_page .tiaozhuan").click(function () {
            var pageNum = $("#txtPageNum").val();
            try {
                pageIndex = parseInt(pageNum);
            } catch (e) {
                alert("请输入数字");
                return false;
            }

            if (pageNum > 0 && pageNum <= pageCount) {
                $("#manage_page").html(PageHtml(pageIndex, pageCount));
                gotoPage();
            }
            else {
                alert("当前数字超出范围");
                return false;
            }
        });
    }
</script>

